package com.lg.utils.hutool.io;

import cn.hutool.core.io.file.FileAppender;
import lombok.SneakyThrows;

import java.io.File;
import java.util.concurrent.TimeUnit;

public class FileAppenderTest {
    @SneakyThrows
    public static void main(String[] args) {
        /**
         * isNewLineMode = true
         * 每一个 append 后面都会加上回车
         */
        FileAppender appender = new FileAppender(new File("C:/Users/imlg/Desktop/test2.txt"), 2, true);

        /**
         * 超过容量会自动 flush
         */
        while (true) {
            appender.append("123");
            appender.append("abc");
            appender.append("xyz");
            appender.append("\n");
            TimeUnit.SECONDS.sleep(1);
            appender.flush();
        }





    }
}
